package com.j.lemon.learn.basic.singleton;


import java.io.*;

public enum EnumSingleton {
    INSTANCE
}

class Te{
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Singleton instance = Singleton.getInstance();
        Singleton instance1 = null;
        FileOutputStream f = new FileOutputStream("/Users/lijunjun/test.obj");
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(f);
        objectOutputStream.writeObject(instance);
        objectOutputStream.flush();
        objectOutputStream.close();

        FileInputStream fileInputStream = new FileInputStream("/Users/lijunjun/test.obj");
        ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
        instance1 = (Singleton) objectInputStream.readObject();
        objectInputStream.close();

        System.out.println(instance==instance1);


    }
}
